<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<html>
<head>
	<title>Nav 5</title>
	<style type="text/css">
	button {
		width: 100%;
		height: 100px;
	}
	</style>
    <script type="text/javascript" src="javascripts/base.js"></script>
	<script type="text/javascript">

	document.addEventListener('runtimeready', function() {
		alert('runtimeready');

		document.addEventListener('pause', function() {
			alert('pause');
		});

		document.addEventListener('resume', function() {
			alert('resume');
		});
	});

	function preload() {
		window.nuva.require('ui.nav').preload({
			pages: [
				{
					id: 'baidu',
					url: 'http://www.baidu.com'
				}
			],
			onSuccess: function(id) {
				alert(id + ' page finished');
			},
			onFail: function(err) {
				alert('preload err: ' + JSON.stringify(err));
			}
		});
	}

	//id是string类型
	function go(id) {
		window.nuva.require('ui.nav').go({
			id: id,
			onSuccess: function(id) {
				alert('go to ' + id);
			},
			onFail: function(err) {
				alert('go err: ' + JSON.stringify(err));
			}
		});
	}

	</script>
</head>
<body>
	<h1>Nav 5</h1>
	<h3>preload baidu, 测试在百度中发生url跳转后，点返回键能正确返回</h3>
	<div><button onclick="preload()">Preload</button></div>
	<div><button onclick="go('baidu')">Go to 'baidu'</button></div>
</body>
</html>